package com.guigu.qingcheng.service;

import com.guigu.qingcheng.pojo.TbAddress;
import com.guigu.qingcheng.pojo.TbAddress;
import com.guigu.qingcheng.pojo.TbOrderItem;
import com.guigu.qingcheng.pojo.TbUser;
import com.guigu.qingcheng.utils.R;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 远程引用UserService的feign接口
 */
@Component
@FeignClient("service-user")
public interface UserServiceFeign {

    @GetMapping(value="/user/user/sendSms")
    public R sendSms(@RequestParam("phone") String phone);

    @PostMapping("/user/user/save")
    public R save(@RequestBody TbUser tbUser , @RequestParam("smsCode") String smsCode );

    // 登录
    @PostMapping("/user/user/login")
    public R loginUser(@RequestBody TbUser tbUser);

    // 获取登录用户信息
    @GetMapping("/user/user/getUserInfo")
    public R getUserInfo(@RequestParam String username);

    //获取微信登陆id
    @GetMapping("/api/ucenter/wx/login")
    public String getWxCode();

    //修改账户密码
    @PostMapping("/user/user/updatePasswordByUsername")
    R updatePasswordByUsername(@RequestBody TbUser user);

    //查询用户地址分页
    @PostMapping("/user/address/pageQueryByAll/{pageNum}/{pageSize}")
    public R pageQueryByAll(@PathVariable("username") String username, @PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize);

    //根据用户查询地址
    @GetMapping("/user/address/detail/{id}")
    public R detail(@PathVariable("id") Integer id);

    //添加地址
    @PostMapping("/user/address/add")
    public R add(@RequestBody TbAddress tbAddress);

    //根据用户修改地址
    @PutMapping("/user/address/update")
    public R update(@RequestBody TbAddress tbAddress);

    //删除地址
    @DeleteMapping("/user/address/delete/{id}")
    public R delete(@PathVariable("id") Integer id);

    // 获取收货地址信息
    @GetMapping("/user/address/findAddressList")
    public List<TbAddress> findAddressList(@RequestParam("username") String username);

    //修改默认地址
    @GetMapping("/user/address/updatetoAddress/{username}/{id}")
    public R updatetoAddress(@PathVariable("username")String username,@PathVariable("id") Integer id);

}
